package com.cmc.cloud.cmclink.doc.api.document;

import cn.hutool.core.collection.CollectionUtil;
import com.cmc.cloud.cmclink.doc.api.document.emums.BookingOpenStatusEnum;
import com.cmc.cloud.cmclink.doc.api.document.emums.ExImTypeEnum;
import com.cmc.cloud.cmclink.doc.api.document.emums.TransmodeEnum;
import com.cmc.cloud.cmclink.doc.api.document.rep.*;
import com.cmc.cloud.cmclink.doc.api.document.req.so.*;
import com.cmc.cloud.cmclink.doc.api.document.req.so.sovo.sovslvoyvo.SoVslvoyUpdateReqVO;
import com.cmc.cloud.cmclink.doc.constant.DocApiConstants;
import com.cmc.cloud.cmclink.doc.constant.SoCreate;
import com.cmes.framework.common.exception.util.ServiceExceptionUtil;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;

/**
 * SO信息查询
 *
 * @author lzp
 */
@FeignClient(name = DocApiConstants.NAME)
@Tag(name = "RPC - 服务 SO信息查询")
public interface SoInfoApi {

    String PREFIX = DocApiConstants.PREFIX + "/so";

    /**
     * SO信息查询
     *
     * @param soPageReqDto
     * @return
     */
    @PostMapping(PREFIX + "/query")
    @Operation(summary = "订单信息查询")
    CommonResult<PageResult<SoRespDto>> querySoInfo(@RequestBody @Valid SoPageReqDto soPageReqDto);

    /**
     * SO全量统计箱数据
     *
     * @param soPageReqDto
     * @return
     */
    @PostMapping(PREFIX + "/querySoForecastCount")
    @Operation(summary = "订单信息查询")
    CommonResult<SoForecastCountVO> querySoForecastCount(@RequestBody @Valid SoPageReqDto soPageReqDto);

    /**
     * 订单详情信息查询
     *
     * @param id
     * @return
     */
    @GetMapping(PREFIX + "/query/{id}")
    @Operation(summary = "订单详情信息查询")
    CommonResult<SoCreateAndUpdateReqDto> querySoDetailInfo(@PathVariable("id") Long id);

    /**
     * 订舱特种货创建、更新、提交
     *
     * @param soCreateAndUpdateReqVo reqVo
     * @return SoAndSpcRespDto
     */
    @PostMapping(PREFIX + "/create")
    @Operation(summary = "订舱创建")
    CommonResult<SoAndSpcRespDto> createSo(@RequestBody @Validated({SoCreate.class}) SoCreateAndUpdateReqDto soCreateAndUpdateReqVo);

    /**
     * 订舱草稿
     *
     * @param soCreateAndUpdateReqVo reqVo
     * @return SoAndSpcRespDto
     */
    @PostMapping(PREFIX + "/createDraft")
    @Operation(summary = "订舱草稿")
    CommonResult<SoAndSpcRespDto> createDraft(@RequestBody @Validated SoCreateAndUpdateReqDto soCreateAndUpdateReqVo);

    /**
     * 订舱确认通知书下载
     *
     * @param soId soId
     * @return FileUploadRespDto
     */
    @PostMapping(PREFIX + "/bookingComfirmPrint/{soId}")
    @Operation(summary = "下载订舱确认通知书接口（订舱审核通过打印）")
    CommonResult<FileUploadRespDto> bookingComfirmPrint(@PathVariable("soId") Long soId);

    /**
     * 订舱确认通知书数据组装
     *
     * @param soId soId
     * @return 订舱确认通知书打印数据
     */
    @GetMapping(PREFIX + "/getBookingConfirmData/{soId}")
    @Operation(summary = "订舱确认通知书数据组装")
    CommonResult<BookingConfirmationDataDto> getBookingConfirmData(@PathVariable("soId") Long soId);


    /**
     * 下载订舱确认通知书接口（订舱审核通过打印）
     *
     * @param ids
     * @return
     */
    @PostMapping(PREFIX + "/bookingConfirmPrint")
    @Operation(summary = "下载订舱确认通知书接口（订舱审核通过打印）")
    CommonResult bookingComfirmPrint(@RequestBody List<Long> ids);


    /**
     * 订舱草稿批量删除
     *
     * @param ids
     * @return
     */
    @PostMapping(PREFIX + "/batchDeleteDraft")
    @Operation(summary = "订舱草稿批量删除")
    CommonResult batchDeleteDraft(@RequestBody List<Long> ids);


    /**
     * 订舱批量审核内容
     *
     * @param ids
     * @return
     */
    @Operation(summary = "订舱批量审核内容")
    @PostMapping(PREFIX + "/batchApproveContent")
    CommonResult batchApproveContent(@RequestBody List<Long> ids);

    /**
     * 订舱COD查看-订舱对比查看
     *
     * @param id
     * @return
     */
    @Operation(summary = "版本查看-订舱对比查看")
    @GetMapping(PREFIX + "/getAmendApplyDetail")
    CommonResult<SoDetailCompareRespDto> getAmendApplyDetail(@PathVariable("id") Long id);

    /**
     * 订舱COD查看-获得订舱详细
     *
     * @param id
     * @return
     */
    @Operation(summary = "订舱COD查看-获得订舱详细")
    @GetMapping(PREFIX + "/getSo")
    CommonResult<SoDetailRespDto> getSo(@PathVariable("id") Long id);

    /**
     * 订舱批量返回草稿
     *
     * @param batchReturnToDraftDto
     * @return
     */
    @Operation(summary = "订舱撤回草稿接口-订舱批量返回草稿")
    @PostMapping(PREFIX + "/batchReturnToDraft")
    CommonResult batchReturnToDraft(@RequestBody BatchReturnToDraftDto batchReturnToDraftDto);

    /**
     * 订舱COD查看-获得订舱详细
     *
     * @param batchReturnToDraftDto
     * @return
     */
    @Operation(summary = "订舱COD查看-获得订舱详细")
    @GetMapping(PREFIX + "/getSoDetailList")
    CommonResult<SoDetailRespDto> getSoDetailList(@RequestBody BatchReturnToDraftDto batchReturnToDraftDto);

    /**
     * 订舱状态统计
     *
     * @param soCountDTO soCountDTO
     * @return
     */
    @Operation(summary = "订舱状态统计")
    @PostMapping(PREFIX + "/countSoStatus")
    CommonResult<List<SoStatusCountVO>> countSoStatus(@RequestBody SoCountDTO soCountDTO);

    /**
     * 获取已确认订舱但是为产生提单的订舱信息
     *
     * @param csmCode 用户企业csmCode
     * @param soStatus so状态
     * @return
     */
    @Operation(summary = "获取已确认订舱但是未产生提单的订舱信息")
    @GetMapping(PREFIX + "/not/order/si/{csmCode}/{soStatus}")
    CommonResult<List<SoAndSpcRespDto>> queryNotOrderSi(@PathVariable("csmCode") String csmCode,
                                                        @PathVariable("soStatus") String soStatus);

    /**
     * 通过订舱soId和用户id批量删除订舱草稿
     *
     * @param userId 用户ID
     * @param soId   soId
     * @return
     */
    @Operation(summary = "通过订舱soId和用户id批量删除订舱草稿")
    @GetMapping(PREFIX + "/batchDeleteDraft/{userId}/{soId}")
    CommonResult<Void> batchDeleteDraft(@PathVariable("userId") String userId, @PathVariable("soId") Long soId);

    /**
     * 通过订舱soId和用户id批量取消
     *
     * @param userId 用户ID
     * @param soId   soId
     * @return
     */
    @Operation(summary = "通过订舱soId和用户id批量取消订舱")
    @GetMapping(PREFIX + "/batchCancelBooking/{userId}/{soId}")
    CommonResult<Void> batchCancelBooking(@PathVariable("userId") String userId, @PathVariable("soId") Long soId);

    /**
     * 通过订舱号查询so详情
     *
     * @param bookingNo 订舱号
     * @return
     */
    @Operation(summary = "通过订舱号查询so详情")
    @GetMapping(PREFIX + "/getSoDetailByBookingNo/{bookingNo}")
    CommonResult<SoRespDto> getSoDetailByBookingNo(@PathVariable("bookingNo") String bookingNo);

    /**
     * 通过订舱号模糊查询so-bookingNo
     *
     * @param bookingNo 订舱号
     * @param csmCode 客户号
     * @return list
     */
    @Operation(summary = "通过订舱号模糊查询so-bookingNo")
    @GetMapping(PREFIX + "/getSoBookingNoList/{bookingNo}/{csmCode}")
    CommonResult<List<SoBookingNoVO>> getSoBookingNoList(@PathVariable("bookingNo") String bookingNo,@PathVariable("csmCode") String csmCode);

    /**
     * SO船期校验
     * @param soVslvoyList 船期数据
     * @return 结果
     */
    @Operation(summary = "SO船期校验")
    @PostMapping(PREFIX + "/checkVslvoy")
    CommonResult<Void> checkVslvoy(@RequestBody List<SoVslvoyUpdateReqVO> soVslvoyList);

}
